package com.feilong.edgeAI;


import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;

public class Main extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
//        findViewById(R.id.btn_start).setOnClickListener(this);
        if (XXPermissions.hasPermission(this, Permission.READ_PHONE_STATE,
                Permission.MANAGE_EXTERNAL_STORAGE)) {
            Log.i("AEE", "has permission");
        } else {
            XXPermissions xxPermissions;
//            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
//                xxPermissions = XXPermissions.with(this).permission(Permission.READ_PHONE_STATE,
//                        Permission.MANAGE_EXTERNAL_STORAGE);
//            } else {
//                xxPermissions = XXPermissions.with(this).permission(Permission.READ_PHONE_STATE,
//                        Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE);
//            }

//            xxPermissions.request(new OnPermission() {
//                @Override
//                public void hasPermission(List<String> granted, boolean isAll) {
//
//                }
//
//                @Override
//                public void noPermission(List<String> denied, boolean quick) {
//                    Toast.makeText(Main.this, "您禁止了该权限，无法获取设备相关标识", Toast.LENGTH_SHORT).show();
//                }
//            });
        }
    }

    @Override
    public void onClick(View view) {

        Intent intent;
        switch (view.getId()) {
//            case R.id.btn_start:
//                intent = new Intent(Main.this, EDActivity.class);
//                startActivity(intent);
//                String sn = getSN();
//                String unknown = SystemPropertiesInvoke.get("ro.boot.serialno", "unknown");

//                break;
            default:
                break;
        }
    }

    public static String getSN() {
        String sn = "null";
//        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
////            Android 10不再支持获取SN，需要系统签名
//            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//                sn = Build.getSerial();
//            } else {
//                sn = Build.SERIAL;
//            }
//        }
        return sn;
    }
}
